<template>
	<view>
		<view class="">
			账号 <input v-model="user.mobile" type="text" value="" />
		</view>
		<view class="">
			密码 <input v-model="user.pass" :password='!isShowPass' value="" />
		  <view @click="showPass" class="yan">
		  	密码可见
		  </view>
		</view>
		<view class="">
			<button @click="login">登录</button>
		</view>
	</view>
</template>

<script>
	import  {checkLogin} from '../../service/member.js'
	export default {
		data() {
			return {
				user:{
					mobile:"",
					pass:""
				},
				isShowPass:false
			}
		},
		methods: {
			showPass(){
				this.isShowPass=!this.isShowPass;
			},
			async login(){
				
				 const {errCode,errMsg,data}=await checkLogin(this.user);
				if(errCode===10000){
					
					console.log(data);
					uni.setStorageSync("token",data.token);
					uni.setStorageSync("member",data.member);
					
					uni.switchTab({
						url:'/pages/index/index'
					})
					
				}
				else{
					uni.showToast({
						title:errMsg,
						icon:'none'
					})
				}
			}
		}
	}
</script>

<style>

</style>
